{% from "devhub/includes/macros.html" import tip, empty_unless %}

<form method="post" action="{{ url('devhub.addons.section', addon.slug, 'additional_details', 'edit') }}">
  <h3>
    {{ _('Additional Details') }}
    {% if not editable %}
      <a href="#" data-editurl="{{ url('devhub.addons.section', addon.slug, 'additional_details', 'edit') }}" class="button">
      {{ _('Edit') }}</a>
    {% endif %}
  </h3>
  <div class="item">
    <div class="item_wrapper">
      {% if editable %}{{ main_form.non_field_errors() }}{% endif %}
      <table>
        <caption>{{ _('Additional Details for {0}')|format_html(addon.name) }}</caption>
        <tbody>
          <tr>
            <th>
              {{ tip(_("Tags"),
                     _("Tags help users find your add-on. You may have a maximum of {0} tags. "
                       "Only choose tags that are relevant to your add-on.").format(amo.MAX_TAGS)) }}
            </th>
            <td id="addon_tags_edit">
              {% if editable %}
                {{ main_form.tags }}
                {{ main_form.tags.errors }}
                <div class="edit-addon-details">
                  {{ _('Limit {0} tags.')|format_html(amo.MAX_TAGS) }}
                </div>
              {% else %}
                {% call empty_unless(tags) %}
                  {{ tags|join(', ') }}
                {% endcall %}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th>
              {{ tip(_("Contributions URL"),
                     _("If you would like to request monetary contributions "
                       "from your users, set this to a page where they can do so.")) }}
            </th>
            <td>
              {% if editable %}
                <p>{{ _('Supported domains: %s'|format(', '.join(amo.VALID_CONTRIBUTION_DOMAINS))) }}</p>
                <p>{{ main_form.contributions }}</p>
                {{ main_form.contributions.errors }}
              {% else %}
                <a href="{{ addon.contributions }}" target="_blank" rel="noopener noreferrer">{{ addon.contributions }}</a>
              {% endif %}
            </td>
          </tr>
          <tr>
            <th>
              {{ tip(_("Default Locale"),
                     _("Information about your add-on is displayed in this locale "
                       "unless you override it with a locale-specific translation. "
                       "It is only relevant for listed add-ons.")) }}
            </th>
            <td class="addon_edit_locale">
              {% if editable %}
                {{ main_form.default_locale }}
                {{ main_form.default_locale.errors }}
              {% else %}
                {{ addon.language_ascii() }}
              {% endif %}
            </td>
          </tr>
          <tr>
            <th>
              <label data-for="homepage">
                {{ _("Homepage") }}
                {{ tip(None,
                       _("If your add-on has another homepage, enter its "
                         "address here. If your website is localized into other "
                         "languages multiple translations of this field can be "
                         "added. It is only relevant for listed add-ons.")) }}
              </label>
            </th>
            <td>
              {% if editable %}
                {{ main_form.homepage }}
                {{ main_form.homepage.errors }}
              {% else %}
                {% call empty_unless(addon.homepage) %}
                  {{ addon|all_locales('homepage') }}
                {% endcall %}
              {% endif %}
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    {% if editable %}
    <div class="listing-footer">
      <button>{{ _('Save Changes') }}</button> {{ _('or') }}
        <a href="{{ url('devhub.addons.section', addon.slug, 'additional_details') }}"
          class="addon-edit-cancel">
          {{ _('Cancel') }}</a>
    </div>
    {% endif %}
  </div>
</form>
